﻿using System.ServiceModel;
using System.ServiceModel.Web;
using Interscape.TwilioClient.Components;
using Interscape.TwilioClient.ServiceHelpers;

namespace Interscape.TwilioClient
{

    #region Service Interface

    [ServiceContract]
    public interface ITranscriptionManager
    {
        [OperationContract]
        [TwilioWcfSerializer]
        [WebGet(
            BodyStyle = WebMessageBodyStyle.Bare,
            ResponseFormat = WebMessageFormat.Xml,
            UriTemplate = "/Accounts/{accountSid}/Transcriptions"
            )]
        TranscriptionList GetAll(string accountSid);

        [OperationContract]
        [TwilioWcfSerializer]
        [WebGet(
            BodyStyle = WebMessageBodyStyle.Bare,
            ResponseFormat = WebMessageFormat.Xml,
            UriTemplate = "/Accounts/{accountSid}/Transcriptions/{transcriptionSid}"
            )]
        Transcription Get(string accountSid, string transcriptionSid);

    }

    #endregion

    public class TranscriptionManager : ManagerBase<ITranscriptionManager>, ITranscriptionManager
    {

        #region Constructors

        /// <summary>
        /// Creates a new instance of the TranscriptionManager.
        /// </summary>
        /// <param name="accountSid">The 34 character string that uniquely identifies the Account which will be used to make the TwilioAPI requests.</param>
        /// <param name="authToken">The "password" for your Twilio API calls.</param>
        public TranscriptionManager(string accountSid, string authToken) : base(accountSid, authToken)
        {
        }

        #endregion

        /// <summary>
        /// Gets a PagedList of all Transcriptions
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        ///The list is sorted by DateUpdated, with newest Transcriptions first. 
        /// </remarks>
        public TranscriptionList GetAll()
        {
            return this.GetAll(this.AccountSid);
        }

        /// <summary>
        /// Gets a PagedList of all Transcriptions
        /// </summary>
        /// <param name="accountSid">A 34 character string that uniquely identifies the Account associated with this resource.</param>
        /// <returns></returns>
        /// <remarks>
        ///The list is sorted by DateUpdated, with newest Transcriptions first. 
        /// </remarks>
        public TranscriptionList GetAll(string accountSid)
        {
            return this.Channel.GetAll(accountSid);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="transcriptionSid"></param>
        /// <returns></returns>
        public Transcription Get(string transcriptionSid)
        {
            return this.Get(this.AccountSid, transcriptionSid);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="accountSid">A 34 character string that uniquely identifies the Account associated with this resource.</param>
        /// <param name="transcriptionSid"></param>
        /// <returns></returns>
        public Transcription Get(string accountSid, string transcriptionSid)
        {
            return this.Channel.Get(accountSid, transcriptionSid);
        }

    }
}
